import $ from '../common';
Page({
  data: {
    // 热门赛事
    list:[],
    page:1,
    tip:'上滑加载更多'
  },
  onLoad(e) {
    const {type='',name=''}=e
    wx.setNavigationBarTitle({
      title: e.name,
    })
    this.setData({
      zonecode:wx.getStorageSync('addresscode')||'',
      type,
      name,
    })
    this.getinfo()
  },
  onShow() {

  },
  getinfo(){//获取赛事
    const{type,zonecode,page}=this.data
    let url
    if(type==1)url='/socialprac/list'
    if(type==2)url='/leveltest/list'
    if(type==3)url='/studytrain/list'
    if(type==4)url='/competition/list'
    let obj={
      page,
      zonecode,
      limit:20
    }
    if(type==3){obj.campus_category='INSTITUTION'}
    console.log(obj);
    $.get(url,obj,res=>{
      console.log(res);
      let data=[]
      if(type==1)data=res.socialprac
      if(type==2)data=res.leveltest
      if(type==3)data=res.studytrain
      if(type==4)data=res.competition
      this.setData({
        list:data
      })
    })
  },
  getsocialprac(){//获取社会实践
    $.get('/socialprac/list',{
      zonecode,
      limit:20,
      page
    },res=>{
      this.setData({
        list:res.competition
      })
    })
  },
  // 去往赛事详情
  goevent(e){
    const {uuid=''}=e.currentTarget.dataset
    $.navigateTo(`/match/matchdetail?uuid=${uuid}&name=${this.data.name}&type=${this.data.type}`)
  },
})